const { expect } = require("chai");
var Web3 = require('web3');
const comtrollerABI = require('./ERC20ABI.json'); // abi信息


const secretIndex = process.argv.indexOf('--secret');
//secretValue 表示私钥
let secretValue;

if (secretIndex > -1) {
    // Retrieve the value after --custom
    secretValue = process.argv[secretIndex + 1];
}

const tokenAddress = (tokenValue || 'Default');

const tokenIndex = process.argv.indexOf('--tokenAddress');
let tokenValue;

if (tokenIndex > -1) {
    // Retrieve the value after --custom
    tokenValue = process.argv[tokenIndex + 1];
}
const tokenAddress = (tokenValue || 'Default');


const approveIndex = process.argv.indexOf('--approveAddress');
let approveValue;

if (approveIndex > -1) {
    // Retrieve the value after --custom
    approveValue = process.argv[approveIndex + 1];
}

const tokenId = process.argv.indexOf('--tokenId');
let tokenIdValue;

if (tokenId > -1) {
    // Retrieve the value after --custom
    tokenIdValue = process.argv[tokenId + 1];
}

var web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org'));
//var web3 = new Web3(new Web3.providers.HttpProvider('https://http-testnet.hecochain.com'));
var wallet = web3.eth.accounts.privateKeyToAccount(secretValue);
web3.eth.accounts.wallet.add(secretValue);
let contractBUSD = new web3.eth.Contract(comtrollerABI,tokenAddress);


web3.eth.getGasPrice()
    .then(console.log);
let tx = contractBUSD.methods.approve(approveValue,tokenIdValue).send({from:wallet.address,gasLimit:50000000,gas:2000000});



